package org.byqh.dqeai.enums;

import org.springframework.http.HttpStatus;

public enum SystemErrorEnum {
    /**
     * -------------------------错误------------------------
     */
    DATA_NOT_EXIST("DATA_NOT_EXIST", "数据不存在", HttpStatus.OK.value()),                      // 数据不存在
    NO_AUTH("NO_AUTH", "权限不足，无法进行此操作", HttpStatus.UNAUTHORIZED.value()),                      // 无权操作
    ERROR_500("ERROR_500", "发生错误，请稍后重试, ERROR_500", HttpStatus.INTERNAL_SERVER_ERROR.value()),             // 500
    ERROR_NP("ERROR_NP", "发生错误，请稍后重试, ERROR_NP", HttpStatus.INTERNAL_SERVER_ERROR.value()),              // NP
    ERROR_CAS("ERROR_CAS", "格式转换错误，请稍后重试, ERROR_CAS", HttpStatus.BAD_REQUEST.value()),           // ClassCastException
    ERROR_IO("ERROR_IO", "发生错误，请稍后重试, ERROR_IO", HttpStatus.INTERNAL_SERVER_ERROR.value()),              // IOException
    ERROR_NSM("ERROR_NSM", "方法不存在，请稍后重试, ERROR_NSM", HttpStatus.BAD_REQUEST.value()),           // NoSuchMethodException
    ERROR_PARAMS("ERROR_PARAMS", "参数错误，请修改后重试, ERROR_PARAMS", HttpStatus.BAD_REQUEST.value()),  // NoSuchMethodException
    ERROR_BIND("ERROR_BIND", "参数错误，请修改后重试, ERROR_BIND", HttpStatus.BAD_REQUEST.value()),  // ERROR_BIND
    ERROR_IOB("ERROR_IOB", "发生错误，请稍后重试, ERROR_IOB", HttpStatus.INTERNAL_SERVER_ERROR.value()),           // IndexOutOfBoundsException
    ERROR_SOF("ERROR_SOF", "发生错误，请稍后重试, ERROR_SOF", HttpStatus.INTERNAL_SERVER_ERROR.value()),           // StackOverflowError
    ERROR_406("ERROR_406", "请求类型错误，请修改后重试, ERROR_406", HttpStatus.NOT_ACCEPTABLE.value()),           // HttpMediaTypeNotAcceptableException
    ERROR_405("ERROR_405", "请求类型错误，请修改后重试, ERROR_405", HttpStatus.METHOD_NOT_ALLOWED.value()),           // HttpRequestMethodNotSupportedException
    ERROR_400("ERROR_400", "参数错误，请修改后重试, ERROR_400", HttpStatus.BAD_REQUEST.value()),           // MissingServletRequestParameterException TypeMismatchException HttpMessageNotReadableException
    /**
     * -------------------------错误------------------------
     */

    /**
     * -------------------------未知服务源------------------------
     */
    DEFAULT("ERROR_DEFAULT", "发生错误码DEFAULT请稍后重试", HttpStatus.BAD_REQUEST.value());
    /**
     * -------------------------未知服务源------------------------
     */
    private String name;
    private String message;
    private Integer status;

    public static String getMessage(SystemErrorEnum systemErrorEnum) {
        return systemErrorEnum.getMessage();
    }

    private SystemErrorEnum(String name, String message, Integer status) {
        this.name = name;
        this.message = message;
        this.status = status;
    }

    public String getName() {
        return name;
    }

    public String getMessage() {
        return message;
    }

    public Integer getStatus() {
        return status;
    }
}
